import { ComponentMetadata, Snippet } from '@alilc/lowcode-types';

const InfrastructureMeta: ComponentMetadata = {
  componentName: 'Infrastructure',
  title: '基础设施',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  group: '设施环境',
  category: '数据展示',
  priority: 0,
  npm: {
    package: 'hzdz-charts',
    version: '0.1.0',
    exportName: 'Infrastructure',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  configure: {
    props: [
      {
        title: '基础配置',
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'title',
            title: '组件标题',
            setter: 'StringSetter',
            defaultValue: '基础设施',
          },
          {
            name: 'englishTitle',
            title: '英文标题',
            setter: 'StringSetter',
            defaultValue: 'Infrastructure',
          },
        ],
      },
      {
        title: '统计数据配置',
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'statisticsData',
            title: '统计数据',
            setter: {
              componentName: 'ArraySetter',
              props: {
                itemSetter: {
                  componentName: 'ObjectSetter',
                  props: {
                    config: {
                      items: [
                        {
                          name: 'label',
                          title: '标签',
                          setter: 'StringSetter',
                        },
                        {
                          name: 'value',
                          title: '数值',
                          setter: 'NumberSetter',
                        },
                      ],
                    },
                  },
                },
              },
            },
            defaultValue: [
              { label: '前端感知设备', value: 16785 },
              { label: '设施', value: 4753 },
              { label: '普通设备', value: 53519 },
            ],
          },
        ],
      },
      {
        title: '事件处理',
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'onClick',
            title: '点击事件',
            setter: 'FunctionSetter',
          },
        ],
      },
      {
        title: '外观',
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'style',
            title: '自定义样式',
            setter: 'StyleSetter',
          },
          {
            name: 'className',
            title: '自定义类名',
            setter: 'StringSetter',
          },
        ],
      },
    ],
    supports: {
      style: true,
      events: ['onClick'],
    },
    component: {},
  },
};

const snippets: Snippet[] = [
  {
    title: '基础设施',
    screenshot: '',
    schema: {
      componentName: 'Infrastructure',
      props: {
        title: '基础设施',
        englishTitle: 'Infrastructure',
        statisticsData: [
          { label: '前端感知设备', value: 16785 },
          { label: '设施', value: 4753 },
          { label: '普通设备', value: 53519 },
        ],
      },
    },
  },
];

export default {
  ...InfrastructureMeta,
  snippets,
};